package logic

import (
	"context"
	"net/http"
	"vip_srv/vipsrvclient"

	"api/internal/svc"
	"github.com/zeromicro/go-zero/core/logx"
)

type RetLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RetLogic {
	return &RetLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RetLogic) Ret(req *http.Request) (resp string, err error) {
	// todo: add your logic here and delete this line
	req.ParseForm()
	snow := req.PostForm.Get("out_trade_no")
	status := req.PostForm.Get("trade_status")
	_, err = l.svcCtx.VipSrv.Update(l.ctx, &vipsrvclient.UpdateRequest{
		Snow:   snow,
		Status: status,
	})
	return "success", nil
}
